﻿#region Using Directives

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Xml.Linq;

    using Csla;

    using MarketPulse.BusinessLogic.Core;
    using MarketPulse.BusinessLogic.Common.Criteria;

#endregion

namespace MarketPulse.BusinessLogic.Common
{
    /// <summary>
    /// </summary>
    [Serializable]
    [Csla.Server.ObjectFactory("MarketPulse.BusinessLogic.DataAccess.LinqSProcEnquiryTypeFactory, DataAccess")]
    public class EnquiryTypeList : MarketPulseNameValueListBase<Guid, string>
    {
        #region Member Variables

            private static EnquiryTypeList mEnquiryTypes;

        #endregion

        #region Constructors

            /// <summary>
            /// Default constructor is private in order to (try to) enforce construction
            /// only via the static factory methods provided.
            /// </summary>
            private EnquiryTypeList()
            {
            }

        #endregion

        #region Methods

            #region Factory Methods

                /// <summary>
                /// Method used to get a list of name/value pairs representing ComponentTypes 
                /// from the database.  Internally this accesses a static field so this
                /// class is effectively a lazily instantiated singleton.
                /// </summary>
                public static void GetList(LanguageCriteria languageCriteria, EventHandler<DataPortalResult<EnquiryTypeList>> callback)
                {

                    if (mEnquiryTypes == null)
                    {
                        DataPortal.BeginFetch<EnquiryTypeList>(languageCriteria, (o, e) =>
                        {
                            mEnquiryTypes = e.Object;
                            callback(o, e);
                        });
                    }
                    else
                    {
                        callback(null, new DataPortalResult<EnquiryTypeList>(mEnquiryTypes, null, null));
                    }
                }

                /// <summary>
                /// Method used to synchronously get a list of name/value pairs representing 
                /// ComponentTypes from the database.  Internally this accesses a static field 
                /// so this class is effectively a lazily instantiated singleton.
                /// </summary>
                public static EnquiryTypeList GetList(LanguageCriteria languageCriteria)
                {
                    //if (mEnquiryTypes == null)
                    //{
                        mEnquiryTypes = DataPortal.Fetch<EnquiryTypeList>(languageCriteria);
                    //}
                    return mEnquiryTypes;
                }

                /// <summary>
                /// Method used to update the list of name/value pairs representing EnquiryTypes
                /// </summary>
                /// <param name="enquiryTypes">The list of name/value pairs to update</param>
                /// <returns>The name/value list resulting from the update</returns>
                public static EnquiryTypeList UpdateComponentTypes(EnquiryTypeList enquiryTypes)
                {
                    return DataPortal.Update<EnquiryTypeList>(enquiryTypes);
                }

            #endregion

        #endregion

        #region Properties

        #endregion

    }
}
